package com.qfedu.edu.utils;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * @author xiaobobo
 * @title: Exceptionutils
 * @projectName CD-Java-JY-2401-Simple-Parent
 * @description: 这个是异常的工具类
 * @date 2024/3/22  14:46
 */
public class ExceptionUtils {
    /**
     * 这个方法的主要作用就是将传递过来的Exception的数据的站信息取出来返回去
     *
     * @param err
     * @return
     */
    public static String getExceptionStackInfo(Throwable err) {
        StringWriter stringWriter = null;
        PrintWriter printWriter = null;
        try {
            stringWriter = new StringWriter();
            printWriter = new PrintWriter(stringWriter);
            err.printStackTrace(printWriter);
            return stringWriter.toString();
        } catch (Exception e) {
            System.out.println("说明出现问题了....");
        } finally {
            try {
                stringWriter.close();
                printWriter.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return null;
    }


}
